
const fs = require("fs")

exports.readHtmlFile = function(req,res,path){
    fs.readFile(path,'utf8',(err,data)=>{
       if(err) throw err;
       res.writeHead(200,{'content-type':'text/html;charset=utf8'});
       res.write(data);
       res.end()
    })
}

exports.readJsonFile = function(req,res,path){
   fs.readFile(path,"utf8",(err,data)=>{
        if(err) throw err;
        res.writeHead(200,{'content-type':'application/json;charset=utf8'});
        res.write(data);
        res.end()
   })
}

exports.readImgFile = function(req,res,path){
  fs.readFile(path,"binary",(err,data)=>{
    if(err) throw err;
    res.writeHead(200,{'content-type':'image/jpeg'});
    res.write(data,'binary');
    res.end();
  })
}